'''Miscellaneous tools for working with dates'''

def firstMonthDates(dates):
    '''Extract the first date of month of
    a given series of dates.
    '''
    out = [dates[0],]
    for i in range(len(dates)-1):
        if dates[i+1].month != dates[i].month:
            out.append(dates[i+1])
    return out
